﻿using System;
using UnityEngine;

namespace Valve.VR.InteractionSystem
{
	// Token: 0x02000657 RID: 1623
	public class TeleportArea : TeleportMarkerBase
	{
		// Token: 0x170004F7 RID: 1271
		// (get) Token: 0x0600294D RID: 10573 RVA: 0x000F0BC0 File Offset: 0x000EEDC0
		// (set) Token: 0x0600294E RID: 10574 RVA: 0x000F0BC8 File Offset: 0x000EEDC8
		public Bounds meshBounds { get; private set; }

		// Token: 0x0600294F RID: 10575 RVA: 0x000F0BD4 File Offset: 0x000EEDD4
		public void Awake()
		{
			this.areaMesh = base.GetComponent<MeshRenderer>();
			this.tintColorId = Shader.PropertyToID("_TintColor");
			this.CalculateBounds();
		}

		// Token: 0x06002950 RID: 10576 RVA: 0x000F0BFC File Offset: 0x000EEDFC
		public void Start()
		{
			this.visibleTintColor = Teleport.instance.areaVisibleMaterial.GetColor(this.tintColorId);
			this.highlightedTintColor = Teleport.instance.areaHighlightedMaterial.GetColor(this.tintColorId);
			this.lockedTintColor = Teleport.instance.areaLockedMaterial.GetColor(this.tintColorId);
		}

		// Token: 0x06002951 RID: 10577 RVA: 0x000F0C5C File Offset: 0x000EEE5C
		public override bool ShouldActivate(Vector3 playerPosition)
		{
			return true;
		}

		// Token: 0x06002952 RID: 10578 RVA: 0x000F0C60 File Offset: 0x000EEE60
		public override bool ShouldMovePlayer()
		{
			return true;
		}

		// Token: 0x06002953 RID: 10579 RVA: 0x000F0C64 File Offset: 0x000EEE64
		public override void Highlight(bool highlight)
		{
			if (!this.locked)
			{
				this.highlighted = highlight;
				if (highlight)
				{
					this.areaMesh.material = Teleport.instance.areaHighlightedMaterial;
				}
				else
				{
					this.areaMesh.material = Teleport.instance.areaVisibleMaterial;
				}
			}
		}

		// Token: 0x06002954 RID: 10580 RVA: 0x000F0CB8 File Offset: 0x000EEEB8
		public override void SetAlpha(float tintAlpha, float alphaPercent)
		{
			Color tintColor = this.GetTintColor();
			tintColor.a *= alphaPercent;
			this.areaMesh.material.SetColor(this.tintColorId, tintColor);
		}

		// Token: 0x06002955 RID: 10581 RVA: 0x000F0CF4 File Offset: 0x000EEEF4
		public override void UpdateVisuals()
		{
			if (this.locked)
			{
				this.areaMesh.material = Teleport.instance.areaLockedMaterial;
			}
			else
			{
				this.areaMesh.material = Teleport.instance.areaVisibleMaterial;
			}
		}

		// Token: 0x06002956 RID: 10582 RVA: 0x000F0D30 File Offset: 0x000EEF30
		public void UpdateVisualsInEditor()
		{
			this.areaMesh = base.GetComponent<MeshRenderer>();
			if (this.locked)
			{
				this.areaMesh.sharedMaterial = Teleport.instance.areaLockedMaterial;
			}
			else
			{
				this.areaMesh.sharedMaterial = Teleport.instance.areaVisibleMaterial;
			}
		}

		// Token: 0x06002957 RID: 10583 RVA: 0x000F0D84 File Offset: 0x000EEF84
		private bool CalculateBounds()
		{
			MeshFilter component = base.GetComponent<MeshFilter>();
			if (component == null)
			{
				return false;
			}
			Mesh sharedMesh = component.sharedMesh;
			if (sharedMesh == null)
			{
				return false;
			}
			this.meshBounds = sharedMesh.bounds;
			return true;
		}

		// Token: 0x06002958 RID: 10584 RVA: 0x000F0DC8 File Offset: 0x000EEFC8
		private Color GetTintColor()
		{
			if (this.locked)
			{
				return this.lockedTintColor;
			}
			if (this.highlighted)
			{
				return this.highlightedTintColor;
			}
			return this.visibleTintColor;
		}

		// Token: 0x04002995 RID: 10645
		private MeshRenderer areaMesh;

		// Token: 0x04002996 RID: 10646
		private int tintColorId;

		// Token: 0x04002997 RID: 10647
		private Color visibleTintColor = Color.clear;

		// Token: 0x04002998 RID: 10648
		private Color highlightedTintColor = Color.clear;

		// Token: 0x04002999 RID: 10649
		private Color lockedTintColor = Color.clear;

		// Token: 0x0400299A RID: 10650
		private bool highlighted;
	}
}
